﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BinaryTree
{
    public class VHeight:IVisit
    {
        private int h = 0;
        public int Amount { get { return h; } }
        public void Visit(treeNode _root)
        {
            if (_root != null)
            {
                IVisit left = new VHeight();
                IVisit right = new VHeight();
                left.Visit(_root.left);
                right.Visit(_root.right);
                h += Math.Max(left.Amount, right.Amount) + 1;
            }
        }
    }
}
